package com.xia.controller;

import com.xia.service.BankService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Api(tags = "导入Excel文件")
@Slf4j
public class BankController {

    @Autowired
    private BankService bankService;

    @RequestMapping(value = "upload",method = RequestMethod.POST)
    public String upload(@RequestParam(value = "file") MultipartFile file) {
        boolean b = false;
        try {
            b = bankService.addBank(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (b) {
            return "导入成功";
        } else {
            return "导入失败";
        }
    }
}
